package com.ocom.webapi.controller;

import com.ocom.common.constant.WebApiServiceUrl;
import com.ocom.common.request.payconfig.food.ComMerchRequest;
import com.ocom.common.request.payconfig.food.FoodClassIdRequest;
import com.ocom.common.request.payconfig.food.NewFoodClassRequest;
import com.ocom.common.resp.Result;
import com.ocom.webapi.feign.PayConfigClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@PreAuthorize("@pms.hasRole('ROLE_WEB')" )
public class FoodstuffClassController {


    @Autowired
    PayConfigClientService payConfigClientService;

    //6.1.1食材分类列表（FoodstuffClass/onShow）
    @PostMapping(WebApiServiceUrl.Url_FoodstuffClassOnShow)
    public Result onShow(@RequestBody ComMerchRequest request) {
        return payConfigClientService.foodClassList(request);
    }

    //6.1.2删除食材分类（FoodstuffClass/delete）
    @PostMapping(WebApiServiceUrl.Url_FoodstuffClassDelete)
    public Result delete(@RequestBody FoodClassIdRequest request) {
        return payConfigClientService.removeFoodClass(request);
    }

    //6.1.3添加食材分类（FoodstuffClass/add）
    @PostMapping(WebApiServiceUrl.Url_FoodstuffClassAdd)
    public Result add(@RequestBody NewFoodClassRequest request) {
        return payConfigClientService.newFoodClass(request);
    }

    //6.1.4修改食材分类（FoodstuffClass/modify）
    @PostMapping(WebApiServiceUrl.Url_FoodstuffClassModify)
    public Result modify(@RequestBody NewFoodClassRequest request) {
        return payConfigClientService.updateFoodClass(request);
    }


}
